﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using AwesomeEnginePC.Graphics;

namespace AwesomeEnginePC.Game.Screens
{
    public abstract class BaseScreen<T> where T : struct
    {
        protected ContentManager cm;

        private bool _firstUpdate;
        public bool ScreenComplete { get; protected set; }
        public T? NextScreen { get; protected set; }

        public void Update(GameTime gameTime)
        {
            if (_firstUpdate)
            {
                _firstUpdate = false;
                ActionOnFirstUpdate(gameTime);
            }

            UpdateInner(gameTime);
        }

        protected abstract void UpdateInner(GameTime gameTime);

        protected virtual void ActionOnFirstUpdate(GameTime gameTime) { }

        public virtual void ResetScreen()
        {
            ScreenComplete = false;
            _firstUpdate = true;
        }

        public abstract void Draw(GameTime gameTime, SpriteBatch sb);

        public BaseScreen(ContentManager contentManager)
        {
            cm = contentManager;
            _firstUpdate = true;
        }

    }
}
